package com.jzo2o.customer.controller.consumer;

import com.jzo2o.customer.model.dto.request.AddressBookPageQueryReqDTO;
import com.jzo2o.customer.model.dto.request.AddressBookUpsertReqDTO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;

@RestController("consumerAddressBookController")
@RequestMapping("/consumer/address-book")
@Api(tags = "地址簿")
public class AddressBookController {


    @PostMapping
    @ApiOperation("地址簿新增")
    public void add(@RequestBody AddressBookPageQueryReqDTO addressBookPageQueryReqDTO) {
        addressBookPageQueryReqDTO.add(addressBookPageQueryReqDTO);
    }


    @PutMapping("/{id}")
    @ApiOperation("地址薄修改")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value="地址薄",required = true,dataTypeClass = Long.class)
    })
    public void update(@NotNull(message = "id不能为空") @PathVariable("id") Long id,
            @RequestBody AddressBookUpsertReqDTO addressBookUpsertReqDTO){
        addressBookUpsertReqDTO.update(id,addressBookUpsertReqDTO);
    }

    @GetMapping("/{id}")
    @ApiOperation("地址簿详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name="id",value="地址薄id",required=true, dataTypeClass = long.class)
    })
    public AddressBookUpsertReqDTO detail(@NotNull(message = "id不能为空") @PathVariable("id")  Long id){
        return null;

    }


}
